package com.ctshk.rpc.order.bus.mapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ctshk.common.service.mapper.CtsBaseMapper;
import com.ctshk.common.utils.Assist;
import com.ctshk.rpc.order.bus.entity.BusOrderCost;

/**
 * 巴士订单成本mapper
 * 
 * @author Qiaoxin.Hong
 *
 */
public interface BusOrderCostMapper extends CtsBaseMapper<BusOrderCost> {

	/**
	 * 查询某订单的旅客相关巴士订单成功
	 * @return key：旅客类型
	 */
	default Map<Integer, BusOrderCost> queryTouristTypeMapByOrder(Long orderId) {
		Map<Integer, BusOrderCost> map = new HashMap<>();
		List<BusOrderCost> list = selectListByKey(BusOrderCost::getOrderId, orderId);
		Assist.forEach(list, entity -> {
			if (entity.getTouristType() != null) {
				map.put(entity.getTouristType(), entity);
			}
		});
		return map;
	}
}
